package meng.dubbo.demo.consume;

import meng.dubbo.demo.model.Student;
import meng.dubbo.demo.service.StudentService;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class StudentServiceTest {

	ClassPathXmlApplicationContext context = null;
	StudentService studentService = null;

	@Before
	public void before() {
		context = new ClassPathXmlApplicationContext("applicationContext.xml");
		context.start();
		studentService = (StudentService) context.getBean("studentService");
	}

	@Test
	public void testGetById() {
		Student student = studentService.getById(1);
		System.out.println("获取姓名 ==> " + student.getStuName());
		System.out.println("获取年级 ==> " + student.getPhase());
	}

	@Test
	public void testAdd() {
		Student student = new Student();
		student.setStuName("鲁班");
		student.setPhase("高中");
		studentService.add(student);
	}

	@After
	public void after() {
		// context.destroy();
	}
}
